Trading Sequence Diagrams
The workflow for several of the trading processes between the client UI application and the
Note: In the following sequences, the four calls
Login & Retrieve Account Information

After login and account information is retrieved, subscribe to the relevant information streams. These subscriptions should always be made at the start of a session after account login.
- CLIENTACCOUNTMARGIN - provides account information and updates such as the current cash balance, margin used, trading resource available and so on.
- DEFAULTPRICES - stream of default prices for a specified account operator. This stream does not require authentication so it can be used on a public web site.
- NEWSHEADLINES - channel of current news headlines.
- ORDERS - channel for orders information and updates.
- PRICES - real time stream of market prices.
- QUOTE - dealer re-quotes channel.
- TRADEMARGIN - provides the current margin requirement for each open trade and also the open trade equity for each trade.
Notes
- When the account credentials are entered into the UI login screen and submitted, POST a LogOnRequestDTO to the <Server Path>/TradingAPI/session URI.
- When login is successful, a session token is returned to the UI application.
-
Upon receipt of a session token, retrieve the account information via HTTP GET to the URI /<Server Path>/TradingAPI/UserAccount/ClientAndTradingAccount.
All requests from stage 3 onwards must carry the Username and Session token as authentication information. This can be in the request header or as a query string.
- The account information such as ClientAccountId and a list of accounts is returned to the UI application.
- At the end of the sequence, the UI application is logged into the account and displays the account information appropriately.
Market Search to Populate a Market Grid

The following sequence assumes the user is a Contracts for Difference (CFD) trader. The sequence shows the process flow to return all CFD markets for the user, as an example, to populate a market grid with constantly updating prices.
Notes
-
Search for all CFD markets applicable to the user account. Perform the search by HTTP GET to the cfd/markets target at URI ?MarketName={searchByMarketName}&MaxResults={maxResults}&ClientAccountId={ClientAccountId}.
Leave the searchbyMarketName parameter empty to perform a search for all markets, for example: MarketName=.
- The response returns the list of applicable CFD markets to the UI application, which can then populate the market grid.
- Get market information for all the CFD markets returned by the initial query in stage 1. Send a POST to the market target at URI /market/information. Send the market IDs for the relevant markets as the parameter.
- The response returns the market information such as ID and name for all the markets obtained in stage 1.
- Subscribe to the price stream to display and update appropriately the prices on the market grid. LightStreamer is used as the push server for prices.
- Prices are pushed to the market grid when an update occurs.
- A market grid of all CFD instruments for the user account is displayed in the UI application, and the prices are updated as changes occur.
Place a Trade via Market Order

The following sequence assumes that the UI application is logged into a trading account, and a price subscription to the market for trading has been made.
The method call to place a trade is denoted in the diagram by the blue shaded box. The other calls denoted by the orange shaded box are to update the account displays for the newly placed trade. Additionally, the calls in marked by the orange box can be made concurrently.
Notes
- To place a trade on a particular market from the UI application, POST a NewTradeOrderRequestDTO to the URI <Server Path>/TradingAPI/order/newtradeorder.
- The response for the trade request indicates the order status such as whether the order was successfully placed, and the status reason.
- Show the new open trade by refreshing the open positions display with a GET to the URI TradingAPI/order/openpositions?TradingAccountId={tradingAccountId}.
- The open positions response provides a list of open positions including the newly placed trade.
-
Refresh the trade history list to show the newly placed trade with a GET to the URI /<Server Path>/TradingAPI/order/tradehistory?TradingAccountId={tradingAccountId}&MaxResults={maxResults}.
- The response contains a list of historical trades.
-
Refresh the active orders list to show any stop loss or take profit orders attached to the newly opened trade. Send a GET to the to the URI /<ServerPath>/TradingAPI/order/activestoplimitordersTradingAccountId={tradingAccountId}.
- A list of all active stop and limit orders is sent in the response, including any new orders attached to the newly opened trade.
-
Refresh the order history to show any new orders that were attached to the newly opened trade. Send a GET to the to the URI /<Server Path>/TradingAPI/order/stoplimithistory?TradingAccountId={tradingAccountId}&MaxResults={maxResults}.
- The response provides a list of historical stop and limit orders.
- The client UI application displays the newly opened trade and any attached orders. The trade and order history is updated to reflect the new trade and any attached stop or limit orders.
Add Stop and/or Limit Order to an Open Trade

The workflow sequence is the same whether adding a Stop or a Limit order to an open trade. If both a Stop and a Limit order are attached to an open trade simultaneously, then stages 3 - 6 are repeated once. This accounts for both orders being added.
The assumption is made that the UI application order ticket shows the current prices for the market in question, and that these prices are updated as changes occur. Note: the LightStreamer prices subscription stage is not shown in the sequence diagram.
The calls in stages 3 - 6 marked by the blue box can be made concurrently.
Notes
- Retrieve the open trade information (using its trade ID as the OrderId parameter) to populate the new order ticket in the UI application. Send a GET to the URI <Server Path>/TradingAPI/order/{orderId}.
- When the new Stop and/or Limit order information is submitted from the UI application, POST an UpdateTradeOrderRequestDTO to the URI <Server Path>/TradingAPI/order/updatetradeorder.
-
Refresh the active orders list to show the new stop loss and/or take profit orders attached to the existing trade. Send a GET to the to the URI <Server Path>/TradingAPI/order/activestoplimitorders?TradingAccountId={tradingAccountId}.
-
Refresh the trade history list to show the newly placed trade with a GET to the URI <Server Path>/TradingAPI/order/tradehistory?TradingAccountId={tradingAccountId}&MaxResults={maxResults}.
- Refresh the open positions list to show the new stop and/or limit order values attached to the trade. Send a GET to the URI <Server Path>/TradingAPI/order/openpositions?TradingAccountId={tradingAccountId}.
-
Refresh the order history list to show the new stop and /or limit order(s) added. Send a GET to the URI <Server Path>/TradingAPI/order/stoplimithistory?TradingAccountId={tradingAccountId}&MaxResults={maxResults}.
- The client UI application shows the new Stop and/or Limit orders attached to an existing trade, and all relevant order and trade windows are updated.
Create an Entry Order

The following workflow sequence assumes that the UI application order ticket shows the current prices for the market in question, and that these prices are updated as changes occur. Note: the LightStreamer PRICES channel subscription stage is not shown in the sequence diagram.
The calls in stages 2 - 5 marked by the blue box can be made concurrently.
Notes
- To create an entry order on a particular market from the UI application: when the user has filled in the order details on the ticket and submitted it, POST a NewStopLimitOrderRequestDTO to the target at URI <Server Path>/TradingAPI/order/newstoplimitorder.
- Refresh the active orders list to show the new entry order just created. Send a GET to the to the URI <Server Path>/TradingAPI/order/activestoplimitorders?TradingAccountId={tradingAccountId}.
-
Refresh the trade history list. This catches the case when the order ticket in the UI application was used to create a market order, and a trade has been placed. Refreshing the trade history list shows this new trade. Send a GET to the URI <Server Path>/TradingAPI/order/tradehistory?TradingAccountId={tradingAccountId}&MaxResults={maxResults}.
- Refresh the open positions list. This catches the case when the order ticket in the UI application was used to create a market order, and a trade has been placed. Refreshing the open positions list shows this new open position. Send a GET to the URI <Server Path>/TradingAPI/order/openpositions?TradingAccountId={tradingAccountId}.
-
Refresh the order history list to show the new entry order. Send a GET to the URI <Server Path>/TradingAPI/order/stoplimithistory?TradingAccountId={tradingAccountId}&MaxResults={maxResults}.
- This sequence ends with the entry order active on the back end server and displayed in the UI application appropriately.
Create a Watchlist

The following sequence assumes that there is currently no watchlist on the trading account, and that this is the first watchlist to be created.
Notes
- To create a new watchlist, open a watchlist creation component by sending a GET to the URI <Server Path>/TradingAPI/watchlists. This returns a list of all currently existing watchlists.
- Save the new watchlist name and/or save the watchlist for each market added into the watchlist. POST an apiSaveWatchlistRequestDTO to the URI <Server Path>/TradingAPI/watchlist/save.
-
Refresh the watchlist display to show each new market added by sending a GET to the <Server Path>/TradingAPI/watchlists URI <Server Path>/TradingAPI/watchlists.
Repeat steps 2 and 3 as required for each market added into the watchlist.
- A watchlist of user selected markets is created and saved under a name chosen by the user.
Delete a Watchlist

It is assumed in the following sequence that a previously created watchlist exists and is no longer required. The sequence shows how the watchlist is removed.
Notes
- Open the Watchlist to be deleted by sending a GET to the URI <Server Path>/TradingAPI/watchlists. This returns a list of all currently existing watchlists, including the watchlist for deletion.
- When the user deletes the watchlist in the client UI application, POST a deleteWatchlistRequestDto to the URI <Server Path>/TradingAPI/watchlist/delete.
- Retrieve all watchlists to check that the deleted watchlist has been removed and close the deleted watchlist component. Send a GET to the URI <Server Path>/TradingAPI/watchlists. This returns a list of all currently existing watchlists. The deleted watchlist is no longer on this list.
- The watchlist has been deleted and removed from the UI application display.
Quote Mode Trading Workflow

The following workflow illustrates how to use the
-
User fills trade ticket with an oversize quantity and the UI application calls theTrade method (using NewTradeOrderRequestDTO).
-
The server sends response (ApiTradeOrderResponseDTO), Quote property is populated indicating quote mode is initiated (ApiQuoteResponseDTO is filled with appropriate properties, e.g. QuoteId, Status and StatusReason).
-
The application listens to Quote stream for QuoteDTOs with QuoteId equal to QuoteId received at step 2 inside ApiQuoteResponseDTO.
-
The application shows prices received from Quote stream at step 3.
-
User presses Accept Quote button.
-
Call Trade method (using NewTradeOrderRequestDTO) again, supplying the QuoteId (from Step 2) and either the BidPrice or OfferPrice, depending on if this is a Sell or Buy trade.
-
Parse the server response (ApiTradeOrderResponseDTO) to see if the trade was successful and display appropriate message.
-
Refresh your open positions, trade history, order history, and active orders display by making appropriate calls (ListOpenPositions, ListTradeHistory, ListStopLimitOrderHistory, ListActiveStopLimitOrders).
Remove Existing Stop/Limit Order Workflow

The following workflow describes the steps to remove an existing stop or limit order that is attached to an open trade.
- In the UpdateTradeOrderRequestDTO, provide the IDs of the order or orders to remove in the OrderId field.
- Set the quantity field to 0 for the Stop order or Limit order that you want to remove. If you set 0 to both the Stop and Limit, then both orders are removed.
- Leave all the other fields as they are ignored.
- POST the UpdateTrade method to the /updatetradeorder URI with the UpdateTradeOrderRequestDTO as the parameter.
![]() |
Copyright © 2025 StoneX